//
//  BYLocationImageViewController.m
//  School+
//
//  Created by Sean Sebastian on 5/24/16.
//  Copyright © 2016 Sean Sebastian. All rights reserved.
//

#import "BYLocationImageViewController.h"

#import "UIImageView+WebCache.h"
#import "masonry.h"

#define baseURL @"http://localhost/SchoolPlus/images/Location/"

@interface BYLocationImageViewController ()

@end

@implementation BYLocationImageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    NSString *str = [NSString stringWithFormat:@"%d-%d-%@.jpg" , self.blog.locationX, self.blog.locationY,self.blog.locationDetail];
    NSString *urlStr = [NSString stringWithFormat:@"%@%@" , baseURL , str];
    NSString *encode = [NSString stringWithCString:[urlStr UTF8String] encoding:NSUTF8StringEncoding];
    
    NSURL *url = [NSURL URLWithString:encode];
    
//    UIImage *imgFromUrl =[[UIImage alloc]initWithData:[NSData dataWithContentsOfURL:url]];
    
    
    NSURL *testurl = [NSURL URLWithString:@"http://localhost/SchoolPlus/images/Location/393-251-kk.jpg"];
    UIImage *imgFromUrl =[[UIImage alloc]initWithData:[NSData dataWithContentsOfURL:testurl]];
    
    NSData *data  = [NSData dataWithContentsOfURL:testurl];

    UIImageView *imageView = [[UIImageView alloc] init];
    [self.view addSubview:imageView];
    [imageView sd_setImageWithURL:url];
    
    NSLog(@"%@" , imageView.image);

    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view).insets(UIEdgeInsetsMake(10,10,10,10));
    }];
    imageView.backgroundColor = [UIColor yellowColor];
    
    self.view.backgroundColor = [UIColor grayColor];
    
    
    
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self dismissViewControllerAnimated:YES completion:nil];
}



@end
